<!--批量文件交易审核-->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
    >
    </ht-search-form>
    <ht-table
      ref="dataTable"
      :multi-select="true"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"

    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="80" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '审核',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                }
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <edit-info-dialog ref="editInfoDialog" :dictMap="dictMap" @editComplete="editComplete"></edit-info-dialog>

  </div>
</template>
<script>
import { apiUrlApproveConfig, approve, approveAll } from "@/api/cnaps/bizMng/batchFileUpload";
import { listPageMixin } from "@/libs/listPageMixin";
import EditInfoDialog from "@/views/cnaps/bizMng/batchFile/batchFileApprove/EditInfo";

export default {
  name: "batchFileApprove",
  mixins: [listPageMixin],
  components: {
    EditInfoDialog,
  },
  data() {
    return {
      opButtonList: () => {
        return [
          {
            label: `批量审核通过`,
            type: "danger",
            clickFun: () => {
              this.approveAll();
            },
          },
          ]
      },

      reqConfig: apiUrlApproveConfig,
      total: 0,
      dataList: [],
      //数据字典
      searchFormDictList: [
        "Cnaps2Dict.DRCTCODE",
        "BIZ_TYPE_111",
        "BIZ_CTGY",
        "PRIORITY3CODE",

      ],
      // 遮罩层
      loading: true,
      // 弹出层标题
      title: "",
      showSearch: true,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        custId:"",
        pkgId:""
      },
      formOptions: [],

      tableBindColumns: [
        { label: `行内系统序号`, prop: "custId", width: "170" },
        { label: `报文标识号`, prop: "pkgId", width: "170" },
        { label: `来往账方向`, prop: "drct",dictCode: "Cnaps2Dict.DRCTCODE", width: "100" },
        { label: `交易货币`, prop: "curcd", width: "170" },
        { label: `金额`, prop: "amount",type:"price", width: "170" },
        { label: `付款人`, prop: "payerName", width: "160", sortable: false },
        { label: `付款账号`, prop: "payerActno", width: "160" },
        { label: `收款人`, prop: "payeeName", width: "160", sortable: false },
        { label: `收款账号`, prop: "payeeActno", width: "160" },
      ],
    };
  },
  computed: {

  },
  created() {
  },
  mounted() {
    this.formOptions = [
      {
        type: "input",
        prop: "custId",
        defaultAttr: {
          label: "行内系统序号",
          placeholder: "请输入行内系统序号",
        },
      },
      {
        type: "input",
        prop: "pkgId",
        defaultAttr: {
          label: "报文标识号",
          placeholder: "请输入报文标识号",
        },
      }
    ];
  },
  methods: {
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },

    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.$refs.dataTable.clearSelection()
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /*审核明细*/
    toViewDetail(row) {
      this.$refs.editInfoDialog.show(row.id);
    },
    approveAll() {
      const ids = this.$refs.dataTable.ids.join(",");
      if(this.$refs.dataTable.ids.length<1){
        this.msgError("请选择交易信息")
        return;
      }
      this.$confirm(
        `是否确认审核 ${this.$refs.dataTable.ids.length} 条数据吗?`,
        "警告",
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: "warning"
        }
      )
        .then((re) => {
          approveAll(ids).then((res) => {
            this.doQuery();
            this.msgSuccess('批量审核成功');
            this.$refs.dataTable.clearSelection()
          }).catch(action => {
            this.doQuery();
            this.$refs.dataTable.clearSelection()
          });
        })
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
